package espaceVisuCarre.java2Dutil;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
import java.util.Collection;
import java.util.LinkedList;

import xmlItunes.Track;

public abstract class FormDrawable implements IDrawable 
{

	protected boolean fill ;
	protected Rectangle2D.Float rect ;
	protected Color color;
	protected LinkedList<Track> tracks ;
	
	/**
	 * @param color the color of this form
	 * @param pos the coordinate of the center this form
	 * @param dim the dimension of this form
	 */
	public FormDrawable(Color color, Point2D.Float center, float width , float height, boolean fill )
	{
		this.fill = fill;
		this.color=color;
		this.rect = new Rectangle2D.Float( center.x , center.y , width , height );
		setCenter(center);
	}
	
	
	
	
	public abstract void draw(Graphics2D g) ;
	
	
	
	public Rectangle2D.Float getRectangle(){
		return (Rectangle2D.Float) rect.clone();
	}
	

	
	

	public Point2D.Float getCenter() 
	{
		Point2D.Float p =new Point2D.Float();
		p.x = (rect.x+rect.width/2);
		p.y = (rect.y+rect.height/2);
		return p;

	}

	
	public void setCenter(Point2D.Float p) 
	{
		p.x = p.x - (rect.width/2);
		p.y = p.y - (rect.height/2);
		rect.x = p.x ; 
		rect.y = p.y ;
	}




	public boolean isFill() {
		return fill;
	}




	public void setFill(boolean fill) {
		this.fill = fill;
	}

	
	public Collection<Track> getTracks() 
	{
		if(tracks==null)return new LinkedList<Track>();
		return tracks;
	}
	
	public void setTracks(Collection<Track> tr) 
	{
		tracks = new LinkedList<Track>(tr);
	}
	
}
